package pta.ch01.ex03;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String input = scanner.nextLine().trim();
            if (input.isEmpty()) continue;
            try {
                int num = Integer.parseInt(input);
                if (num >= 10000 && num <= 20000) {
                    System.out.println(
                            Integer.toBinaryString(num) + "," +
                                    Integer.toOctalString(num) + "," +
                                    Integer.toHexString(num)
                    );
                } else {
                    processDigits(input);
                }
            } catch (NumberFormatException e) {
            }
        }
    }
    private static void processDigits(String s) {
        int sum = 0;
        StringBuilder output = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (Character.isDigit(c)) {
                int digit = Character.getNumericValue(c);
                output.append(digit).append(" ");
                sum += digit;
            }
        }
        if (output.length() > 0) {
            output.append(sum);
            System.out.println(output.toString().trim());
        }
    }
}